package cn.javabb.log.action;

import cn.javabb.core.model.StatusEnum;
import cn.javabb.log.action.base.BaseActionMap;
import cn.javabb.log.action.base.ResetLog;

/**
 * @desc:
 * @author: javabb (javabob(a)163.com)
 * @create: 2019/10/27 23:50
 */
public class StateAction extends BaseActionMap {
    @Override
    public void init() {
    // 记录数据状态改变日志
        putMethod("default", "defaultMethod");
    }

    /**
     * 重新包装保存的数据行为方法
     * 接收参数必须是ids
     * @param resetLog ResetLog对象数据
     */
    @SuppressWarnings("unchecked")
    public static void defaultMethod(ResetLog resetLog) {
        if(resetLog.isSuccessRecord()){
            //String state = (String) resetLog.getParam("state");
            StatusEnum statusEnum = StatusEnum.get((Integer)resetLog.getParam("state"));
            String ids =  (String)resetLog.getParam("ids");
            resetLog.getLog().setMessage(statusEnum.getDesc() + "ID：" + ids);
        }
    }

}
